// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   SendTradingProcessor.java

package com.boci.clientapp.trading.processor;

import com.boci.clientapp.trading.vo.SendHKTradingVO;
import com.boci.clientapp.trading.vo.SendUSTradingVO;
import com.boci.common.constant.RequestTypeConst;
import com.boci.common.processor.AbstractResponseProcessor;
import com.boci.common.vo.ResponseVO;

public class SendTradingProcessor extends AbstractResponseProcessor
{

    public SendTradingProcessor(String pXML, String pReqType)
        throws Exception
    {
        super(pXML, pReqType, "TRADING.ERROR_");
    }

    public ResponseVO processXML()
        throws Exception
    {
        String strReqType = getReqType();
        if(strReqType.equals(RequestTypeConst.BOCI_HK_TRADE_SEND_URL))
            return processHKXML();
        if(strReqType.equals(RequestTypeConst.BOCI_US_TRADE_SEND_URL))
            return processUSXML();
        else
            return null;
    }

    public ResponseVO processHKXML()
        throws Exception
    {
        String strOrderID = getNodeValue("ORDER_ID");
        String strAccountID = getNodeValue("ACCOUNT_ID");
        String strSymbol = getNodeValue("SYMBOL");
        String strName = getNodeValue("NAME");
        String strChiName = getNodeValue("NAME_CHI");
        String strChsName = getNodeValue("NAME_CHS");
        String strBuyOrSell = getNodeValue("BUY_OR_SELL");
        String strQuantity = getNodeValue("QUANTITY");
        String strPrice = getNodeValue("PRICE");
        String strOrderType = getNodeValue("ORDER_TYPE");
        String strOrderQual = getNodeValue("ORDER_QUALIFIER");
        String strDate = getNodeValue("DATE");
        String strReqType = getReqType();
        SendHKTradingVO confirmVO = new SendHKTradingVO(strReqType, getReturnCode());
        confirmVO.setOrderID(strOrderID);
        confirmVO.setAccountID(strAccountID);
        confirmVO.setSymbol(strSymbol);
        confirmVO.setName(strName);
        confirmVO.setName_CHI(strChiName);
        confirmVO.setName_CHS(strChsName);
        confirmVO.setBuyOrSell(strBuyOrSell);
        confirmVO.setQuantity(strQuantity);
        confirmVO.setPrice(strPrice);
        confirmVO.setOrderType(strOrderType);
        confirmVO.setOrderQualifier(strOrderQual);
        confirmVO.setDate(strDate);
        return confirmVO;
    }

    public ResponseVO processUSXML()
        throws Exception
    {
        String strOrderID = getNodeValue("ORDER_ID");
        String strAccountID = getNodeValue("ACCOUNT_ID");
        String strSymbol = getNodeValue("SYMBOL");
        String strName = getNodeValue("NAME");
        String strChiName = getNodeValue("NAME_CHI");
        String strChsName = getNodeValue("NAME_CHS");
        String strBuyOrSell = getNodeValue("BUY_OR_SELL");
        String strQuantity = getNodeValue("QUANTITY");
        String strPrice = getNodeValue("PRICE");
        String strOrderType = getNodeValue("ORDER_TYPE");
        String strDate = getNodeValue("DATE");
        String strReqType = getReqType();
        SendUSTradingVO confirmVO = new SendUSTradingVO(strReqType, getReturnCode());
        confirmVO.setOrderID(strOrderID);
        confirmVO.setAccountID(strAccountID);
        confirmVO.setSymbol(strSymbol);
        confirmVO.setName(strName);
        confirmVO.setName_CHI(strChiName);
        confirmVO.setName_CHS(strChsName);
        confirmVO.setBuyOrSell(strBuyOrSell);
        confirmVO.setQuantity(strQuantity);
        confirmVO.setPrice(strPrice);
        confirmVO.setOrderType(strOrderType);
        confirmVO.setDate(strDate);
        return confirmVO;
    }
}
